<?php
include_once('header.inc');
$progid = $_GET['progid'];
$sql = "SELECT * FROM paddata WHERE progid=$progid ";
$database->setQuery($sql);
$result = $database->loadAssocList();
//print_r($result);
foreach ($result as $query){
	$progid       = $query["progid"];
	$company      = htmlspecialchars($query["company"]);
	$website      = htmlspecialchars($query["website"]);
	$title        = htmlspecialchars($query["title"]);
	$version      = $query["version"];
	$pdate        = $query["pdate"];
	$cost         = sprintf("%01.2f",$query["cost"]);
	$download	  = $query['download'];
	$category     = $query['category'];
	$ptype        = $query["ptype"];
	$status       = $query["status"];
	$os           = str_replace(",",", ",$query["os"]);
	$ksize        = $query["ksize"];
	$keywords     = str_replace(",",", ",htmlspecialchars($query["keywords"]));
	$key_word     = explode(",",$keywords);
	$description  = htmlspecialchars($query["description"]);
	$icon         = $query["icon"];
	$affiliate    = htmlspecialchars($query["affiliate"]);
	$affiliateid  = $query["affiliateid"];
	$dlcount      = $query["dlcount"];
	$siterating   = $query["siterating"];
	$screenshot   = $query["screenshot"];
	$descrlarge   = $query["descrlarge"];
	$category1    = explode("::",$category);
	$category2    = rawurlencode($category);
	$statustxt = "<span class=\"red\">new</span>";
	if($status == "1") {
		$statustxt = "<span class=\"green\">update</span>";
	}
	if($icon == "none") $iconimg = "images/noicon.gif";
	else $iconimg = $icon;
    $result1 = mysql_query("SELECT userrating FROM usrreviews WHERE progid='$progid'");
	$userratingsum = "0";
	while($query2 = mysql_fetch_array($result1)) {
		$userratingsum += $query2["userrating"];
	}
	$ratedusers = mysql_num_rows($result1);
	
	// Establishing the displaying of users rating
	$userratingaver = "0"; // By default users ratings average is set to 0
	if($ratedusers > "0") { // If any related entries found
		$userratingaver = $userratingsum / $ratedusers; // Counting users ratings average
	}
	$userratingdisp = "images/u0.gif";
	if($userratingaver > "0" && $userratingaver <= "1") {
		$userratingdisp = "images/u1.gif";
	}
	if($userratingaver > "1" && $userratingaver <= "1.5") {
		$userratingdisp = "images/u15.gif";
	}
	if($userratingaver > "1.5" && $userratingaver <= "2") {
		$userratingdisp = "images/u2.gif";
	}
	if($userratingaver > "2" && $userratingaver <= "2.5") {
		$userratingdisp = "images/u25.gif";
	}
	if($userratingaver > "2.5" && $userratingaver <= "3") {
		$userratingdisp = "images/u3.gif";
	}
	if($userratingaver > "3" && $userratingaver <= "3.5") {
		$userratingdisp = "images/u35.gif";
	}
	if($userratingaver > "3.5" && $userratingaver <= "4") {
		$userratingdisp = "images/u4.gif";
	}
	if($userratingaver > "4" && $userratingaver <= "4.5") {
		$userratingdisp = "images/u45.gif";
	}
	if($userratingaver > "4.5") {
		$userratingdisp = "images/u5.gif";
	}
	$siteratingdisp = "";
	if($siterating == "1") {
		$siteratingdisp = "images/r1.gif";
	}
	if($siterating == "2") {
		$siteratingdisp = "images/r2.gif";
	}
	if($siterating == "4") {
		$siteratingdisp = "images/r3.gif";
	}
	if($siterating == "5") {
		$siteratingdisp = "images/r5.gif";
	}
	if($status==1){
		$pic = "<img src=\"images/upd.gif\" width=\"61\" height=\"21\">";
	}else {
		$pic = "<img name=\"\" src=\"images/new.gif\" width=\"23\" height=\"12\" alt=\"\">";
	}
	$discounturl =$query["discounturl"];
	$discounturl_img = "";
	if($discounturl!="")$discounturl_img = "<a href=$discounturl><img src=images/discount-10p.gif border=0 height=12 width=23></a>";
	//Establishing the displaying of order link
	$buynowlnk = "";
	if($affiliate && $affiliateid) {
		$pick = "<img name=\"\" src=\"images/pick.gif\" width=\"23\" height=\"12\" alt=\"\">";
		if($affiliate == "RegNow") {
			$affiliatelnk = "https://www.regnow.com/softsell/nph-softsell.cgi?affiliate=" . $regnowafl . "&item=" . $affiliateid;
		}
		if($affiliate == "Share-It") {
			$affiliatelnk = "https://secure.shareit.com/shareit/checkout.html?affiliateid=" . $shareitafl . "&productid=" . $affiliateid;
		}
		if($affiliate == "eSellerate") {
			$affiliatelnk = "http://store.esellerate.net/a.asp?c=0_" . $affiliateid . "_" . $esellerateafl;
		}
		if($affiliate == "Plimus") {
			$affiliatelnk = "https://www.plimus.com/jsp/buynow.jsp?contractId=" . $affiliateid . "&referrer=" . $plimusafl;
		}
		if($affiliatelnk) {
			$buynowlnk = "<a href=\"" . $affiliatelnk . "\">buy now</a>";
		}
	}
	
}
$category2 		= base64_encode($category2);
$category1_url = base64_encode($category1[0]);
?>
<table width="980" height="100%" 
border="0" align="center" cellpadding="0" cellspacing="0"  class="gen_tb">
  
  <tr>
    <td height="15" valign="bottom" bgcolor="#cccccc"></td>
    <td colspan="2" align="center" valign="top">
    <td align="left" valign="top" class="main-name-h"><?php echo"<a href=index.html>Home&gt;&gt;</a><a href=index02_w_$category1_url.html>".$category1[0]."</a>&gt;&gt<a href=index02_w_$category2.html>".$category1[1]."</a>"?>
    <td colspan="2" align="center" valign="top">        
    <td valign="bottom" bgcolor="#cccccc"></td>
  </tr>
  <tr>
    <td height="1230" valign="bottom" bgcolor="#cccccc"></td>
    <td width="201" align="left" valign="top"> <table>
    <tr><td>
<?php
$which_class=$category;
include_once("categories1.inc");
?>   
</td></tr> 
<tr><td>
      <p><BR class="main-txt">
      </p>
      <?php include_once('goo-ad1.inc')?>
</td></tr> 
<tr><td>     
      <BR>
      <?php include_once('goo-ad2.inc')?>
</td></tr> 
<tr><td> 
      <br>
      <TABLE width=180 
            border=0 align="center" cellPadding=0 cellSpacing=0 
            background="images/middle.gif">
        <TBODY>
          <TR>
            <TD width="8" height="2" class="table-top"></TD>
            <TD width="172" class="table-top"></TD>
          </TR>
          <TR>
            <TD align=left vAlign=center class="left-rss">:<BR>
                <BR>
                </p>
                </p></TD>
            <TD align=left vAlign=center class="left-rss"><span class="left-b"><img src="images/rss.gif" width="36" height="14">RSS Feeds</span><br>
                <img src="images/rss-1.gif" alt="new" width="14" height="14"><a href="rss.php">New Releases and Updates</a><br>
                  <img src="images/rss-1.gif" alt="new" width="14" height="14"><a href="rss.php?feed=popular">Most Popular Software</a><br>
                  <img src="images/rss-1.gif" alt="new" width="14" height="14"><a href="rss.php?feed=rating">Top Rated Software</a>
          </TR>
          <TR>
            <TD height="8" colspan="2" class="table-bottom"></TD>
          </TR>
        </TBODY>
      </TABLE>
</td></tr> </table>
    <td width="1" valign="top" background="images/line--3.gif">    
    <td width="544" valign="top"><TABLE cellSpacing=0 cellPadding=0 width="98%" align=center 
            border=0>
      <TBODY>
        <TR>
          <TD height="10" colspan="2" class=main-name><IMG height=1 
                  src="Atomic Alarm Clock, The Time Machine, Ez OFF, ___ - Desktop » Clocks &amp; Alarms.files/pixel.gif" 
                  width=1 border=0></TD>
          </TR>
     
        <TR>
          <TD width="322" height="22" class=box_tbl_e><span class="main-txt"> <span class="main-name"><a href="index04_p_<?php echo $progid?>.html"><?php echo $title."　".$version ?></a><?php echo $pick.$pic.$discounturl_img?></span></span></TD>
          <TD width="211" align="center" class=main-image><img src="images/r1.gif" width="100" height="22" alt=""></TD>
        </TR>
        <TR>
          <TD height="38" class=name><div class="P-P"><?php echo $description?></div></TD>
          <TD rowspan="2" align="center" valign="middle" class=box_tbl_e><img src="<?php echo $screenshot?>" width="170" height="120" alt=""></TD>
          </TR>
        <TR>
          <TD height="42" class=name><div class="P-P"><span class="P-B"><strong>Publisher</strong></span><strong>:</strong> <a href="company_company_<?php echo $company?>.html"><?php echo $company?></a><BR>
                <span class="P-B">Downloads</span>:<?php echo $dlcount?><BR>
                <span class="P-B">Updated</span>:<?php echo $pdate?> <BR>
                <strong>Release Status</strong>:<?php echo $pic?><br>
            <span class="P-B">Platform</span>:<?php echo $os?> <BR>
            <strong>Users Rating:</strong>:<img src=<?php echo $userratingdisp;?> width="85" height="10"> <strong><A href="reviews_p_<?php echo $progid;?>.html">R (<?php echo $ratedusers?>)</A></strong>    <strong><A href="revpost_p_<?php echo $progid;?>.html">W</A></strong><BR>
              <span class="P-B">License</span>:<?php echo $ptype?><br>
		    	 <span class="P-B">Cost</span>:$<?php echo $cost?></p>
            </div></TD>
          </TR>
        <TR>
          <TD height="199" colspan="2" valign="top" class=p><p><img name="" src="<?php echo $iconimg?>" width="32" height="32" alt=""><?php echo $descrlarge?>
            <div class="p-db">
              <p><a href="<?php echo $affiliatelnk?>"><img src="images/buy.gif" width="237" height="37" border="0"></a> <a href="download_p_<?php echo $progid?>.html"><img src="images/download.gif" width="250" height="37" border="0"></a> </p>
              </div> </TD>
          </TR>
        <TR>
          <TD height="15" colspan="2" valign="top" class=P-B>Key words : <span class="p-key"><?php foreach ($key_word as $raw){$rawurl = rawurlencode(trim($raw));echo "<a href=search_keykeywords_words$rawurl.html>".$raw."</a> ,";}?></span></TD>
          </TR>
        <TR>
          <TD height="20" colspan="2" valign="top" class=box_tbl_e><script type="text/javascript"><!--
google_ad_client = "pub-6483729784911405";
//250x250, 创建于 07-11-14
google_ad_slot = "0562359498";
google_ad_width = 250;
google_ad_height = 250;
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></TD>
        </TR>
<?php 
$sql = "SELECT * FROM features WHERE progid=$progid";
$database->setQuery($sql);
$result1 = $database->loadAssocList();
if($result1){
?>        
        <TR>
          <TD  colspan="2" valign="top" class=main-txt><span class="P-B">Features:</span><br>
          <?php echo $result1[0]['content']?> <hr width="100%" color='eee5ff'></TD>
          </TR>
<?php 
}
?>          
        <TR>
          <TD height="16" colspan="2" class=box_tbl_h><TABLE width="100%">
            <TBODY>
              <TR>
                <TD width="49%" height="161"><div class="main-name"><strong class="main-image">New releases &amp; updates</strong></div>
                        <table>
<?php
##############################################New releases###########################################
$sql="SELECT * FROM paddata  ORDER BY pdate desc, status LIMIT 15";
$database->setQuery($sql);
$result = $database->loadAssocList();
foreach ($result as $query){  
	$progid       = $query["progid"];
	$title        = htmlspecialchars($query["title"]);
	$status       = $query["status"];
	$statustxt = "NEW";
	if($status == "1") {
		$statustxt = "UPd";
	}
echo "<tr><td><a href=\"index04_p_$progid.html\"><span class=\"nw\">$title</a></span></td><td> <font color=red size=1>$statustxt</font></td><tr>";
}        
?>
</table></TD>
                <TD width="51%"><div class="name"><strong class="main-name">Most popular software</strong></div>
                      <table>
<?php
##############################################Most popular software###########################################
$sql="SELECT * FROM paddata ORDER BY dlcount desc, pdate desc LIMIT 15";
$database->setQuery($sql);
$result = $database->loadAssocList();
foreach ($result as $query){  
	$progid       = $query["progid"];
	$title        = htmlspecialchars($query["title"]);
	$status       = $query["status"];
	$statustxt = "NEW";
	if($status == "1") {
		$statustxt = "UPd";
	}
echo "<tr><td><a href=\"index04_p_$progid.html\"><span class=\"nw\">$title</a></span></td><td> <font color=red size=1>$statustxt</font></td><tr>";
}        
?>
</table>          </TD>
              </TR>
            </TBODY>
          </TABLE></TD>
        </TR>
        <TR>
          <TD height="16" colspan="2" class=box_tbl_h></TD>
          </TR>
      </TBODY>
    </TABLE>
    <td width="1" valign="top" background="images/line--3.gif">    
    <td width="230" align="center" valign="top"><table class=solidb cellspacing=0 cellpadding=0 width="85%" 
            align=center border=0>
      <tbody>
        <tr>
          <td height="22" align=middle valign=top class="name"><p class="right">Spotlight</p></td>
        </tr>
      <?php
##############################################Spotlight###########################################
$sql="SELECT * FROM paddata where spotlight=1 ORDER BY progid desc, pdate desc LIMIT 10";
$database->setQuery($sql);
$result = $database->loadAssocList();
foreach ($result as $query){  
	$progid       = $query["progid"];
	$title        = htmlspecialchars($query["title"]);
	$status       = $query["status"];
	$description  = htmlspecialchars($query["description"]);  
	$screenshot   = $query["screenshot"];
	if($screenshot=="none")   
    $screenshot   = WEBSITE."/images/screenshot.gif";
     echo "<tr>
          <td 
                background=\"images/line-3.gif\" class=\"name\"><img 
                  height=1 
                  src=\"images/1-bg.gif\" 
                  width=1 border=0></td>
        </tr>
        <tr>
          <td valign=top class=\"name\"><img height=17 hspace=3 
                  src=\"images/arrow-b.gif\" 
                  width=4 align=absMiddle border=0><b class=\"right-name\"><a href=\"index04_p_$progid.html\" target=_blank> $title</a></b></td>
        </tr>
        <tr>
          <td width=\"40%\" height=\"183\" align=middle valign=top class=\"g-ding\"><img src=\"$screenshot\"width=\"100\" height=\"100\" 
                  vspace=10 border=0><br>
            $description<br>
            <br></td>
        </tr>";
}
 ?>  
        <tr>
          <td height="2" 
                background="images/line-3.gif"><img 
                  height=1 
                  src="images/1-bg.gif" 
                  width=1 border=0></td>
        </tr>
      </tbody>
    </table>
      <br>
    <td valign="bottom" bgcolor="#cccccc"></td>
  </tr>
  <tr>
    <td height="2" valign="bottom" bgcolor="#cccccc"></td>
    <td colspan="5" align="center" valign="top" background="images/line-3.gif">
    <td valign="bottom" bgcolor="#cccccc"></td>
  </tr>
  <tr>
    <td width="1" height="37" valign="bottom" bgcolor="#cccccc"></td>
    <td colspan="5" align="center" valign="top">
    <td width="1" valign="bottom" bgcolor="#cccccc"></td>
  </tr>
</table>
<?php
include_once('fooder.inc');
?>